<template>
	<view class="container" :style="{height:`calc(100vh - ${height}px)`}">
		<Header back :title="title"></Header>
		<view class="wapper">
			<!-- waterfall -->
			<waterfall v-if="list.length > 0" :dataList="list" @del="delPic"></waterfall>
			<u-empty v-else mode="list"></u-empty>
			<div class="upload" @click="upload">上传</div>
		</view>
	</view>
</template>

<script>
	import Header from '@/components/haeder.vue'
	import waterfall from '@/components/waterfall.vue'
	import banner1 from '@/static/banner/banner1.png'
	export default {
		components: {
			Header,
			waterfall
		},
		data() {
			return {
				height: 0,
				content: '',
				title: '展台照片',
				head: '',
				bannerList: [],
				user: '',
				list: []
			}
		},
		methods: {
			async upload() {
				uni.navigateTo({
					url: './upload'
				})
			},
			async delPic(v) {
				let res = await this.$api.delPic({
					PictureID: v.PictureID
				})
				this.list = await this.$api.getYuYueList({
					OpenID: this.user.OpenID
				})
			}
		},
		async onPullDownRefresh() {
			let res = await this.$api.getPics({
				ChangShangID: this.user.ZhanShangInfo.ZhangShangID || 31,
				PageSize: 9999,
				PageIndex: 1
			})
			this.list = res.UserData
			uni.stopPullDownRefresh()
		},
		async mounted() {
			this.user = uni.getStorageSync('user')
			// this.$nextTick(() => {

			// 	this.list = [
			// 		{
			// 			"PictureID": 14,
			// 			"PictureName": "现场照片22",
			// 			"ImageUrl": "@/upload/images/2023/5/t_cc6dc658fc6204c4.jpg",
			// 			"QiYeID": 31,
			// 			"AddDateTime": "2023-05-23T23:21:39"
			// 		},
			// 		{
			// 			"PictureID": 8,
			// 			"PictureName": "五粮液现场1",
			// 			"ImageUrl": "@/upload/images/2023/5/t_544d7c3c677c3390.jpg",
			// 			"QiYeID": 31,
			// 			"AddDateTime": "2023-05-20T18:02:10"
			// 		},
			// 	]
			// })
			let res = await this.$api.getPics({
				ChangShangID: this.user.ZhanShangInfo.ZhangShangID || 31,
				PageSize: 9999,
				PageIndex: 1
			})
			this.list = res.UserData
		},
		created() {
			let app = uni.getSystemInfoSync();
			this.height = app.windowBottom
		}
	}
</script>

<style scoped lang="scss">
	.container {
		width: 100vw;
		overflow: auto;
		display: flex;
		flex-direction: column;

		.wapper {
			flex: 1;
			background: #f2f2f2;
			z-index: 100;
			margin-top: -280rpx;

			.upload {
				font-size: 26rpx;
				position: fixed;
				right: 20rpx;
				bottom: 20rpx;
				border-radius: 50%;
				color: #fff;
				text-align: center;
				line-height: 60rpx;
				width: 60rpx;
				height: 60rpx;
				padding: 20rpx;
				background: #5272d7;
			}
		}
	}
</style>